package com.ize.controller.admin;

import com.ize.entity.dto.huifuDto;
import com.ize.entity.vo.ConsultationVo;
import com.ize.entity.vo.LishiHuiFuVo;
import com.ize.result.Result;
import com.ize.service.ConsultationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/look")
@Slf4j
@Api(tags = "问诊相关接口")
@RequiredArgsConstructor
public class ConsultationController {

    private final ConsultationService consultationService;

    @GetMapping
    @ApiOperation("获取病人留言")
    public Result<List<ConsultationVo>> look() {
        log.info("正在获取病人消息................");
        return Result.success(consultationService.List());
    }

    @GetMapping("/info")
    @ApiOperation("获取详情留言")
    public Result<ConsultationVo> consultation(@RequestParam Long id) {
        log.info("留言id:{}",id);
        return Result.success(consultationService.getConsulation(id));
    }

    @PostMapping
    @ApiOperation("回复留言")
    public Result add(@RequestBody huifuDto consultation) {
        log.info("消息id：{},用户id：{}，医生恢复：{}",consultation.getId(),consultation.getUser_id(),consultation.getContent());
        consultationService.huifu(consultation);
        return Result.success();
    }


    /**
     * 删除留留言
     * @param id
     * @return
     */
    @DeleteMapping
    @ApiOperation("删除留言")
    public Result delete(@RequestParam Long id) {
        log.info("删除留言id:{}",id);
        consultationService.delete(id);
        return Result.success();
    }

    @GetMapping("/lishi")
    @ApiOperation("历史回复")
    public Result<List<LishiHuiFuVo>> lishi() {
        log.info("正在查询历史回复。。。。。。。");
        return Result.success(consultationService.listConsultation());
    }
}
